-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setup TagField to work within AssetAdmin (Fixes #107) #120
Setup TagField to work within AssetAdmin (Fixes #107) #120
Conversation
I think this PR mostly looks good, but there's a couple of breaking changes that would need to be adjusted and polished. Also I've just made a PR at #122 which will cause a couple of conflicts with adding the same logic in this PR in places |
Happy if @robbieaverill you want to incorporate the bits needed into #122 and close this. |
@wilr I might try and do it on bug day tomorrow |
(Context: #122 with these changes applied) Hrmmm, I've got the fields rendering correctly in asset admin but when I have If I use a regular Does this PR actually save @wilr? @ScopeyNZ are you able to provide any advice here in terms of how this field interacts with redux-form? Again related: silverstripe/silverstripe-admin#639 |
@robbieaverill Yep saves perfectly, been running in prod for a couple weeks now. But this is using composer.lock (https://gist.github.com/wilr/68ed4e6eb9f063da4e00dec6831e0a98). Note the |
@wilr In this PR I've noticed that I get an undefined index error when using the fields on a non-React form, and that StringTagField isn't working in the React context yet. It does look like this PR does make TagField work correctly in a React context, so thank you for that! I'll try and work out why #122 isn't based off of this and move it to that. |
Yeah OK, I can get it working in either entwine or React context but not both at the same time (this PR is the same). I've raised an issue at silverstripe/silverstripe-admin#755 for tracking. I suspect we'll have to refactor more of the logic in TagField to get this to work, and probably do as you've suggested here and switch to extending MultiSelectField. I'll leave this PR open |
It took me wayyyy too long but I finally got around to having a go at fixing this. I've tested this using the blog module and using elemental in-line editing to render a tag field in the React context. For the react context you'll need the admin PR merged as a dependency (silverstripe/silverstripe-admin#912) otherwise the values won't appear in the field. |
@ScopeyNZ is that the only dependency for this PR, e.g. once the admin PR is merged will this PR fix the original issue? |
Yeah we spoke about this a little offline. The admin PR ensures that the field value is correctly set from redux state. So I think this only matters in the elemental context. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Reviewing" so that I can stop being a requested reviewer 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When viewing a BlogPost and creating tags, everything works fine.
On saving a BlogPost with new tags, everything works fine.
On saving a BlogPost with existing tags, everything is not fine.
- Current tags are removed from the relationship
- An equal number of
new
tags are created and assigned to the relationship - These new tags have the Title and URLSegment of the ID field of the tags they're replacing.
Reproduction
Create a BlogPost
Assign tags "one" and "two" (two separate tags).
Save - See "one" and "two" assigned.
Reload - see "one" and "two" assigned.
Save - see "1" and "2" assigned.
Save - see "3" and "4" assigned.
Save - see "5" and "6" assigned.
Reload - see "5" and "6" assigned.
Environment
"repositories": [
{
"type": "vcs",
"url": "[email protected]:creative-commoners/silverstripe-admin"
},
{
"type": "vcs",
"url": "https://github.com/wilr/silverstripe-tagfield/"
}
],
"require": {
"silverstripe/recipe-plugin": "^1",
"silverstripe/recipe-cms": "^4.4",
"dnadesign/silverstripe-elemental": "^4.3",
"silverstripe/elemental-fileblock": "^2.0",
"silverstripe/elemental-bannerblock": "^2.0",
"silverstripe/blog": "^3.3",
"silverstripe/admin": "dev-pulls/1.4/field-names-in-disarray as 1.4.1",
"silverstripe/tagfield": "dev-fixes/107-tagfield-in-admin as 2.3.0"
},
Testing as per #107 OP seems to work fine. Tags do not appear to "duplicate" themselves.
Thanks @NightJar . There was some confusion about IDs vs label titles. Should be squared away now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some small questions. Let's also make this a minor release rather than a patch, because we're adding some new APIs, replacing the react-select library with a newer one, and changing the API response structure
Thanks @ScopeyNZ - can confirm latest update has resolved that issue :) |
This also fixes an issue where tags would be created and tags could not have the same name as the ID of an existing tag And the react-select module is updated to the (current) latest 1.x version And the tests are now working again after updating jest
Ok I've addressed feedback and rebased for a minor release. Thanks for the review @robbieaverill & @NightJar! |
Good result everyone! |
Form field now appears, can be added and searched.
This also fixes missing label